package com.github.wenzi.deviltrainingfour.service.impl;

import com.github.wenzi.deviltrainingfour.dao.ArticleRepository;
import com.github.wenzi.deviltrainingfour.dto.ArticleQueryDto;
import com.github.wenzi.deviltrainingfour.entity.Article;
import com.github.wenzi.deviltrainingfour.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

@Service
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    private ArticleRepository articleRepository;
    @Override
    public Page<Article> query(ArticleQueryDto dto) {
        PageRequest pageRequest = PageRequest.of(dto.getPage()-1,dto.getSize());
        Page<Article> page = articleRepository.findAll(pageRequest);
        return page;
    }
}
